import { FormProps, FormSchema } from '@/components/Table'
import { BasicColumn } from '@/components/Table/src/types/table'
import dayjs, { Dayjs } from 'dayjs'
import { getBeforeTime } from '@/utils/dateUtil'

export function getCompanyBasicColums(): BasicColumn[] {
  return [
    {
      title: '用户手机号码',
      customEllipsis: true,
      width: 90,
      fixed: 'left',
      dataIndex: 'phoneNumber'
    },
    {
      title: '渠道名称',
      width: 150,
      customEllipsis: true,
      dataIndex: 'channelName'
    },
    {
      title: '付费类型',
      width: 80,
      dataIndex: 'payFlag'
    },
    {
      title: '会话ID',
      width: 150,
      customEllipsis: true,
      dataIndex: 'sessionId'
    },
    {
      title: '会话名称',
      width: 140,
      customEllipsis: true,
      dataIndex: 'sessionTitle'
    },
    {
      title: '问题',
      width: 140,
      customEllipsis: true,
      dataIndex: 'qcontent'
    },
    {
      title: '回答',
      width: 140,
      dataIndex: 'acontent'
    },
    {
      title: '点赞/点踩',
      width: 140,
      dataIndex: 'likeStatus'
    },
    {
      title: '是否删除',
      width: 80,
      dataIndex: 'sessionDeleted'
    },
    {
      title: '创建时间',
      width: 140,
      dataIndex: 'createTime'
    },
    {
      title: '操作',
      width: 50,
      fixed: 'right',
      dataIndex: 'operate'
    }
  ]
}

const statusArr = [
  {
    label: '全部',
    value: '',
    key: ''
  },
  {
    label: '空',
    value: 'none',
    key: 'none'
  },
  {
    label: '点赞',
    value: 'good',
    key: 'good'
  },
  {
    label: '点踩',
    value: 'bad',
    key: 'bad'
  }
]

export function getSearchFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 100,
    baseColProps: {
      span: 6,
      md: 10,
      xl: 8,
      xxl: 6
    },
    schemas: [
      {
        field: '[creatTimeBegin,creatTimeEnd]',
        label: '创建时间',
        component: 'RangePicker',
        defaultValue: [getBeforeTime(31, 'day'), getBeforeTime(0, 'day')],
        componentProps: {
          valueFormat: 'YYYY-MM-DD',
          format: 'YYYY-MM-DD',
          disabledDate: (current: Dayjs) => {
            return current && current.isAfter(dayjs().startOf('day'), 'day')
          }
        }
      },
      {
        field: 'channelNoList',
        label: '渠道名称',
        component: 'TreeSelect',
        slot: 'channelCode'
      },
      {
        field: 'phoneNumber',
        label: '用户手机号',
        component: 'Input',
        componentProps: {
          maxLength: 11
        }
      },
      {
        field: 'qcontent',
        label: '问题',
        component: 'Input',
        componentProps: {
          maxLength: 200
        }
      },
      {
        field: 'acontent',
        label: '回答',
        component: 'Input',
        componentProps: {
          maxLength: 200
        }
      },
      {
        field: 'likeStatus',
        label: '点赞/点踩',
        component: 'Select',
        defaultValue: '',
        componentProps: {
          options: statusArr
        }
      }
    ]
  }
}
